package top.hihuzi;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.Instant;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.LongStream;

@SpringBootApplication
@EnableDiscoveryClient
@EnableEurekaClient
@RestController
public class AppConsumer {
    public static void main(String[] args) {
        SpringApplication.run(AppConsumer.class, args);
    }

    @RequestMapping("/")
    public Object tosay() {
        Instant instant = Instant.now();
        long epochMilli = instant.toEpochMilli();
        return epochMilli % 2 == 0 ? IntStream.range(1, 100).mapToObj(operand -> "Consumer").collect(Collectors.joining("@", "--", "--"))
                : LongStream.range(1, 100).mapToObj(operand -> "".join("C", "--", "--")).collect(Collectors.toList());
    }
}


